import { ApiProperty } from '@nestjs/swagger';
import {
  IsBoolean,
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  Min,
} from 'class-validator';
import { PaymentMethodType } from '../../entities/payment.entity';

export class CreatePaymentDto {
  @ApiProperty({ description: '订单ID', example: 1 })
  @IsNumber()
  @IsNotEmpty({ message: '订单ID不能为空' })
  orderID: number;

  @ApiProperty({
    description: '支付金额',
    example: 1500,
    minimum: 0,
  })
  @IsNumber()
  @Min(0, { message: '支付金额不能为负数' })
  @IsNotEmpty({ message: '支付金额不能为空' })
  amount: number;

  @ApiProperty({
    description: '支付方式',
    enum: ['线下到店支付', '微信支付', '支付宝支付'],
    default: '线下到店支付',
    example: '线下到店支付',
  })
  @IsEnum(['线下到店支付', '微信支付', '支付宝支付'], {
    message: '支付方式必须是线下到店支付、微信支付或支付宝支付',
  })
  @IsOptional()
  paymentMethod?: PaymentMethodType = '线下到店支付';

  @ApiProperty({
    description: '是否已支付',
    default: false,
    example: false,
  })
  @IsBoolean()
  @IsOptional()
  isPaid?: boolean = false;
}
